Repository navigation
Conversation
Store GenExpr.children as a C list and the numeric expression fields (Constant.number, SumExpr.constant, ProdExpr.constant, PowExpr.expo) as C doubles. Update the stub return types accordingly and note the conversion-on-construction in the changelog.
PowExpr.expo is now stored as a double, so the exponent is rendered as e.g. -1.0 instead of -1.
| class Constant(GenExpr): | ||
| @property | ||
| def number(self) -> SupportsFloat: ... | ||
| def number(self) -> float: ... |
There was a problem hiding this comment.
numebr is float now, not like float. SupportsFloat uses the __float__ protocol.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Hey @Zeroto521 , are there no more changes of this type that you have planned? If there are, please apply them all here. |
The concrete Cython field types make Decimal operands work at runtime, so the generator now emits additional assert_type checks that mypy reports.
- Declare `expr` as `ExprLike` and `_lhs`/`_rhs` as objects using `cdef readonly`, so they can no longer be reassigned from Python. - Type `__init__` with a non-optional `ExprLike expr` and `Optional[float]` bounds. - Sync `scip.pyi`: expose the three fields as read-only properties and take `ExprLike` as the `expr` parameter type.
| cdef readonly ExprLike expr | ||
| cdef readonly object _lhs | ||
| cdef readonly object _rhs | ||
|
|
||
| def __init__( | ||
| self, | ||
| ExprLike expr not None, | ||
| lhs: Optional[float]=None, | ||
| rhs: Optional[float]=None, | ||
| ): |
There was a problem hiding this comment.
Since ExprCons is fewer than 100 lines, I'd like to refactor all ExprCons-related code in a single PR. But it's okay to do in this PR.
Expression fields (
Constant.number,SumExpr.constant,ProdExpr.constant,PowExpr.expo,GenExpr.children) were untyped Python attributes that were only convertedto C types when used. This PR gives them concrete Cython types (
double/list), so valuesare converted once on assignment; the stubs now return
floatfor the numeric fields.